<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('入库质检任务')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">质检单号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="zjdh" name="zjdh" placeholder="质检单号"/>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="质检单号"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">任务状态</label>
                        <select name="rkrwzt" lay-filter="aihao">
                            <option value=""></option>
                            <option value="">全部</option>
                            <option value="0">初始</option>
                            <option value="1">任务创建</option>
                            <option value="2">部分完成</option>
                            <option value="3">全部完成</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="gysmc" name="gysmc" placeholder="客户订单号"/>
                        </div>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">查询</a>
                    </div>
                    <div class="moreSearch" style="display: none">


                        <div class="layui-inline">
                            <label class="layui-form-label">创建时间</label>
                            <div class="layui-input-inline" id="qq">
                                <input type="text" class="layui-input" id="cjsj" name="cjsj" placeholder="请选择时间范围" />
                            </div>
                        </div>
                        <input type="hidden" id="cjsj_start" name="cjsj_start">
                        <input type="hidden" id="cjsj_end" name="cjsj_end">
                    </div>
                </form>
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                <!-- Single button -->
            </div>
            <section class="panel panel-padding layui-card-body">
                <div class="pro">
                    <table id="table" class="table text-nowrap"></table>
                </div>
            </section>
        </div>
    </div>
</div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script>

    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    });
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                /*这里激活状态那个按钮用不到，啥都不需要写，只读*/
            },
            "click #addRkQuality": function (e, value, row, index) {//行发运
                addRkQuality(row.id);
            },
            "click #seach": function (e, value, row, index) {//行创建装车单
                seach(row.id);
            }
        }
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;


        //创建时间开始
        laydate.render({
            elem: '#cjsj',
            type: 'date',
            range: '~',
            done: function(value, date, endDate){
                if(value!=null && value!=""){
                    var start=value.toString().substring(0,value.toString().indexOf("~"));
                    var end=value.toString().substring(value.toString().indexOf("~")+1);
                    $("#cjsj_start").val(Date.parse(new Date(start)));
                    $("#cjsj_end").val(Date.parse(new Date(end)));
                }else {
                    $("#cjsj_start").val("");
                    $("#cjsj_end").val("");
                }

                console.log(value); //得到日期生成的值，如：2017-08-18
                console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
            }
        });
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/wmsqualityinspectionlist/rkRwList',
            columns: [{
                field: 'ckmc',
                title: '仓库名称'
            }, {
                field: 'ownerMc',
                title: '货主名称'
            }, {
                field: 'gysmc',
                title: '供应商名称'
            }, {
                field: 'zjdh',
                title: '质检单号'
            }, {
                field: 'asnbh',
                title: 'ASN编号'
            }, {
                field: 'cjsj',
                title: '创建时间'
            }, {
                field: 'show_zt',
                title: '质检状态'
            }, {
                field: 'show_rkrwzt',
                title: '入库任务状态'
            }, {
                field: 'zjr',
                title: '质检人'
            }, {
                field: 'caozuo',
                title: '操作',
                events: operateEvent,
                formatter:operateFormatter
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });
        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            if(row.rkrwzt==0&&row.zt==2){
                return [
                    '<a class="layui-btn layui-btn-warm layui-btn-xs" id="addRkQuality">生成</a>',
                    '<a class="layui-btn layui-btn-xs" id="seach">查看</a>'

                ].join('')
            }else{
                return [
                    '<a class="layui-btn layui-btn-xs" id="seach">查看</a>'

                ].join('')
            }
        }
        //查询
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })


        //生成入库质检单
        function addRkQuality(id) {
            zzpUtils.dialog({
                title: "生成入库质检任务",
                type: 2,
                content: "/task/addQuality?ids="+id,
                area: ['50%', '40%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
        //查看入库质检任务详情
        function seach(id) {
            zzpUtils.dialog({
                title: "查看入库质检任务详情",
                type: 2,
                content: "/task/lookQuality?ids="+id,
                area: ['80%', '70%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        }
    });

</script>
</html>